<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Animoso.Domain.Album>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h4>Albums</h4>
 <fieldset>
    <table>
    <% foreach (var album in Model)
    {
           %>
        <tr id="album_<%=album.Id %>">
            <td><b><%=album.Name %></b></td>
            <td><%=album.DateTime.ToShortDateString() %></td>            
            <td><a href="<%=Url.Action("Edit", "Album", new { id = album.Id}) %>"><img src="Content/Images/Text-Edit-icon.png" /></a></td>
            <td><a id="delete_<%=album.Id %>" class="deleteAlbum" href="#"><img src="Content/Images/File-Delete-icon.png" /></a></td>
        </tr>
    <% } %>        
    </table>
 </fieldset>
 <p>
        <%= Html.ActionLink("Nieuw Album", "Create") %>
 </p>
</script>

    
<script type="text/javascript">
    $('.deleteAlbum').click(function(event) {        
    var albumId = this.id.split('_')[1];

    $.ajax({ url: "Album/Delete", data: "albumId=" + albumId, context: document.body,
        success: function(val) {
        $('#album_' + albumId).remove();
        }
    });
});
$('.deleteAlbum').confirm();
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
</asp:Content>
